package com.itheima.controller;

import com.itheima.common.R;
import com.itheima.dto.LoginDto;
import com.itheima.service.EmpService;
import com.itheima.vo.LoginVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 处理员工登录请求
 */
@RestController
@Slf4j
public class LoginController {

    @Autowired
    private EmpService empService;

    /**
     * 员工登录
     *
     * @param dto
     * @return
     */
    @PostMapping("/login")
    public R login(@RequestBody LoginDto dto) {
        log.info("员工登录:{}", dto);
        LoginVo vo = empService.login(dto);
        return R.ok(vo);
    }


}
